<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>用户登录 - 小憨堡</title>
        <script src="../static/js/jquery-3.2.1.js"></script>
        <link rel="stylesheet" href="../static/bootstrap-3.3.7-dist/css/bootstrap.css" />
        <link rel="stylesheet" href="../static/css/style.css" />
        <script>
            function login() {
                if ($("#username").val() == "") {
                    alert("请输入用户名");
                    return;
                }
                if ($("#password").val() == "") {
                    alert("请输入密码");
                    return;
                }
                $.post(
                    "/login", {
                        username: $("#username").val(),
                        password: $("#password").val()
                    }, function (data, status) {
                        if (data.code == 0) {
                            alert("登录成功");
                            window.location = "/index.html";
                        } else {
                            alert("用户名或密码不正确！");
                        }
                    }
                );
            }
        </script>

    </head>
    <body>
        <div class="login-bg">
            <div class="login-logo"></div>
            <div class="col-md-3 login">
                <div class="login-header">登录</div>
                <div class="form-group">
                    <div class="login-input form-inline">用户名：</div>
                    <div class="login-text form-inline"><input class="form-control" type="text" id="username" /></div>
                </div>
                <div class="form-group">
                    <div class="login-input form-inline">密码：</div>
                    <div class="login-text form-inline"><input class="form-control" type="password" id="password" /></div>
                </div>
                <hr />
                <div class="form-group">
                    <button class="btn btn-success form-control" onclick="login()">登录</button>
                </div>
            </div>
        </div>
    </body>
</html>